$(function () {
    function checkacc() {
        account = $("input[name='account']").val();
        if(account.length<=3){
            outspan = "<span class='wrong_type'>用户名太短</span>"
            $("#spacc").html(outspan);
            return 0
        }
        return 1
    }
    function checkpass() {
        pwd = $("input[name='pwd']").val();
        if(pwd.length<=5){
            outspan = "<span class='wrong_type'>密码太短</span>"
            $("#pwdcc").html(outspan);
            return 0
        }
        return 1
    }
    function login() {
        var fd = new FormData();
        account = $("input[name='account']").val();
        pwd = $("input[name='pwd']").val();
        csrftoken = $("input[name='csrfmiddlewaretoken']").val();
        fd.append("account",account);
        fd.append("pwd",pwd);
        fd.append("csrfmiddlewaretoken",csrftoken);
        $.post("/login", data = fd, success = function (data) {
            if (data.rels == 200) {
                window.location.href = "/index"
            } else if (data.rels == 201) {
                outspan = "<span class='wrong_type'>用户名错误</span>";
                $("#spacc").html(outspan)
            } else {
                outspan = "<span class='wrong_type'>密码错误</span>"
                $("#pwdcc")
            }
        })
    }
    $("input[name='account']").bind("input propertychange",checkacc);
    $("input[name='pwd']").bind("input propertychange",checkpass);
    $("#")
});